package com.dr.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.ModelAndViewDefiningException;

import com.dr.pojo.User;
import com.dr.service.LoginService;

@RestController
@RequestMapping("/ajax")
public class LoginController_ajax {
	@Autowired
	private LoginService service;
		
	@RequestMapping("/login")
	public Map login(User user, HttpSession session) {		
		Map<String, Object> result = new HashMap<>();		
		User loginUser = service.findUser(user);
		if (loginUser == null) {
			//登录失败			
			result.put("status", "0");//返回标记
		}else {
			session.setAttribute("LoginUser", loginUser); //登录用户记录Session		
			result.put("status", "1");//返回标记
		}		
		return result;
	}
}
